﻿
<script src="~/vue/dist/vue.global.js"></script>
<link href="~/element-plus/dist/index.css" rel="stylesheet" />
<script src="~/element-plus/dist/index.full.js"></script>
<script src="~/axios/dist/axios.js"></script>
<div id="app">
    <el-row>
        <el-col :span="24">
            您正在做的业务是:人力资源--调动管理--调动审核
        </el-col>
    </el-row>
    <el-row>
        <el-col :span="24" style="text-align: right">
            <el-radio-group v-model="mc.CheckStatus" v-on:change="radio1()">
                <el-radio value="通过">通过</el-radio>
                <el-radio value="不通过">不通过</el-radio>
            </el-radio-group>
            &nbsp;
            <el-button type="primary" v-on:click="Xg()">提交</el-button>
            <el-button v-on:click="Fh()">返回</el-button>
        </el-col>
    </el-row>
    <el-row style="height: 10px"></el-row>
    @* 1 *@
    <el-row>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            档案编号
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-input v-model="mc.HumanId" size="small" style="width: 150px;" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            姓名
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-input v-model="mc.HumanName" size="small" style="width: 150px;" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            原I-II-III级机构
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-cascader v-model="index" :options="data" :props="props" style="width: 150px;" size="small" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            原职位分类-名称
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-cascader v-model="index2" :options="data2" :props="props" style="width: 150px;" size="small" readonly />
        </el-col>
    </el-row>
    @* 2 *@
    <el-row>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            原薪酬标准
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-select v-model="mc.SalaryStandardId" size="small" style="width: 150px;" placeholder="请选择">
                <el-option v-for="i in data3" :label="i.standardName" :value="i.standardId" />
            </el-select>
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            新I-II-III级机构
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-cascader v-model="index3" :options="data" :props="props" ref="refs" v-on:change="Change" style="width: 150px;" size="small" placeholder="请选择" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            新职位分类-名称
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-cascader v-model="index4" :options="data2" :props="props" ref="refs2" v-on:change="Change2" style="width: 150px;" size="small" placeholder="请选择" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            新薪酬标准
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-select v-model="mc.SalaryStandardId" size="small" style="width: 150px;" placeholder="请选择">
                <el-option v-for="i in data3" :label="i.standardName" :value="i.standardId" />
            </el-select>
        </el-col>
    </el-row>
    @* 3 *@
    <el-row>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            登记人
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-input v-model="mc.Register" size="small" style="width: 150px;" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            登记人时间
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-input v-model="mc.RegistTime" size="small" style="width: 150px;" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            复核人
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-input v-model="mc.Checker" size="small" style="width: 150px;" readonly />
        </el-col>
        <el-col :span="3" style="border: 1px solid black; background-color: #ffd553;">
            复核时间
        </el-col>
        <el-col :span="3" style="border: 1px solid black;">
            <el-input v-model="mc.CheckTime" size="small" style="width: 150px;" readonly />
        </el-col>
    </el-row>
    @* 4 *@
    <el-row style="height: 70px">
        <el-col :span="3" style="line-height: 70px; border: 1px solid black; background-color: #ffd553;">
            调动原因
        </el-col>
        <el-col :span="21" style="border: 1px solid black;">
            <el-input v-model="mc.ChangeReason" type="textarea" rows="3" size="small" style="width: 1050px;" />
        </el-col>
    </el-row>
    @* 5 *@
    <el-row style="height: 70px">
        <el-col :span="3" style="line-height: 70px; border: 1px solid black; background-color: #ffd553;">
            复合通过意见
        </el-col>
        <el-col :span="21" style="border: 1px solid black;">
            <el-input v-model="mc.CheckReason" type="textarea" rows="3" size="small" style="width: 1050px;" />
        </el-col>
    </el-row>
</div>

<script type="text/javascript">
        window.userTrueName = '@ViewBag.UserTrueName'; // 将ViewBag的值赋给全局变量，方便Vue实例获取
    const { createApp, ref, reactive } = Vue
    const { ElMessage } = ElementPlus

    var app = createApp({
        setup() {
            const data = ref([])
            const data2 = ref([])
            const data3 = ref([])
            const index = ref(null)
            const index2 = ref(null)
            const index3 = ref(null)
            const index4 = ref(null)
            const refs = ref(null)
            const refs2 = ref(null)
            const mc = reactive({
                MchId: null,
                HumanId: null,
                HumanName: null,
                FirstKindId: null,
                FirstKindName: null,
                SecondKindId: null,
                SecondKindName: null,
                ThirdKindId: null,
                ThirdKindName: null,
                MajorKindId: null,
                MajorKindName: null,
                MajorId: null,
                MajorName: null,
                SalaryStandardId: null,
                NewFirstKindId: null,
                NewFirstKindName: null,
                NewSecondKindId: null,
                NewSecondKindName: null,
                NewThirdKindId: null,
                NewThirdKindName: null,
                NewMajorKindId: null,
                NewMajorKindName: null,
                NewMajorId: null,
                NewMajorName: null,
                NewSalaryStandardId: null,
                ChangeReason: null,
                Register: null,
                RegistTime: null,

                CheckStatus: "",
                CheckReason: null,
                Checker:  window.userTrueName,
                CheckTime: null,
            })
            const props = reactive({
                label: "label",
                value: "value",
                children: "children",
            })
            function Show() {
                //mc.Checker = localStorage.getItem("Name")
                setInterval(() => {
                    const now = new Date();
                    let hours = now.getHours();
                    let minutes = now.getMinutes();
                    let seconds = now.getSeconds();

                    // 添加零以确保时、分、秒是两位数
                    let hour = (hours < 10) ? '0' + hours : hours;
                    let minute = (minutes < 10) ? '0' + minutes : minutes;
                    let second = (seconds < 10) ? '0' + seconds : seconds;

                    mc.CheckTime = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()} ${hour}:${minute}:${second}`;
                }, 1000)
                axios.get("/HF/Cascaders2")
                    .then(res => {
                        data.value = res.data
                    })
                    .catch(err => {
                        console.log(err);
                    })
                                axios.get("/CM/Cascaders")
                    .then(res => {
                        data2.value = res.data
                    })
                    .catch(err => {
                        console.log(err);
                    })
                axios.get("/HF/XCBZSelect")
                    .then(res => {
                        data3.value = res.data
                    })
                    .catch(err => {
                        console.log(err);
                    })
                axios.get("/MC/GetMCById")
                    .then(res => {
                        console.log(res.data)
                        mc.MchId = res.data.mchId
                        mc.HumanId = res.data.humanId
                        mc.HumanName = res.data.humanName
                        mc.FirstKindId = res.data.firstKindId
                        mc.FirstKindName = res.data.firstKindName
                        mc.SecondKindId = res.data.secondKindId
                        mc.SecondKindName = res.data.secondKindName
                        mc.ThirdKindId = res.data.thirdKindId
                        mc.ThirdKindName = res.data.thirdKindName
                        mc.MajorKindId = res.data.majorKindId
                        mc.MajorKindName = res.data.majorKindName
                        mc.MajorId = res.data.majorId
                        mc.MajorName = res.data.majorName
                        mc.SalaryStandardId = res.data.salaryStandardId
                        mc.NewFirstKindId = res.data.newFirstKindId
                        mc.NewFirstKindName = res.data.newFirstKindName
                        mc.NewSecondKindId = res.data.newSecondKindId
                        mc.NewSecondKindName = res.data.newSecondKindName
                        mc.NewThirdKindId = res.data.newThirdKindId
                        mc.NewThirdKindName = res.data.newThirdkindName
                        mc.NewMajorKindId = res.data.newMajorKindId
                        mc.NewMajorKindName = res.data.newMajorKindName
                        mc.NewMajorId = res.data.newMajorId
                        mc.NewMajorName = res.data.newMajorName
                        mc.NewSalaryStandardId = res.data.newSalaryStandardId
                        mc.ChangeReason = res.data.changeReason
                        mc.Register = res.data.register
                        mc.RegistTime = res.data.registTime
                        index.value = [mc.FirstKindId, mc.SecondKindId, mc.ThirdKindId]
                        index2.value = [res.data.majorKindId, res.data.majorId]
                        index3.value = [mc.NewFirstKindId, mc.NewSecondKindId, mc.NewThirdKindId]

                        //index3.value = [res.data.newFirstKindId, res.data.newSecondKindId, res.data.newThirdKindId]
                        index4.value = [mc.NewMajorKindId, mc.NewMajorId]
                    })
                    .catch(err => {
                        console.log(err);
                    })
            }
            function Xg() {
                console.log(mc);
                axios.put("/MC/MCUpdate", null, {
                    params: mc
                })
                    .then(res => {
                    })
                    .catch(err => {
                        console.log(err);
                    })
                if (mc.CheckStatus == "通过") {
                    axios.put("/MC/HFDUpdate", null, {
                        params: {
                            id: mc.HumanId,
                            fd: mc.NewFirstKindId,
                            fn: mc.NewFirstKindName,
                            sd: mc.NewSecondKindId,
                            sn: mc.NewSecondKindName,
                            td: mc.NewThirdKindId,
                            tn: mc.NewThirdKindName,
                            kd: mc.NewMajorKindId,
                            kn: mc.NewMajorKindName,
                            md: mc.NewMajorId,
                            mn: mc.NewMajorName,
                            salary: mc.NewSalaryStandardId,
                        }
                    })
                        .then(res => {
                        })
                        .catch(err => {
                            console.log(err);
                        })
                }
                ElMessage({
                    type: 'success',
                    message: '审核成功！'
                });
                setInterval(()=>{
                    window.location.href = "/MC/Index2";
                },1000)
            }
            function Fh() {                                                 
                window.history.back()
            }
            function Change() {
                const a = [];
                const b = [];
                const arr = refs.value.getCheckedNodes()[0].pathNodes;
                arr.forEach((i) => {
                    a.push(i.label);
                    b.push(i.value);
                });
                mc.NewFirstKindId = b[0];
                mc.NewFirstKindName = a[0];
                mc.NewSecondKindId = b[1];
                mc.NewSecondKindName = a[1];
                mc.NewThirdKindId = b[2];
                mc.NewThirdKindName = a[2];
            }
            function Change2() {
                const a = [];
                const b = [];
                const arr = refs2.value.getCheckedNodes()[0].pathNodes;
                arr.forEach((i) => {
                    a.push(i.label);
                    b.push(i.value);
                });
                mc.NewMajorKindId = b[0];
                mc.NewMajorKindName = a[0];
                mc.NewMajorId = b[1];
                mc.NewMajorName = a[1];
            }
            Show()

            function radio1(){
                mc.CheckReason = mc.CheckStatus
            }
            return {
                data,
                data2,
                data3,
                index,
                index2,
                index3,
                index4,
                refs,
                refs2,
                props,
                mc,
                Show,
                Xg,
                Fh,
                Change,
                Change2,radio1
            }
        }
    })
    app.use(ElementPlus)
    app.mount('#app')
</script>

<style scoped>
    body {
        background-color: #ffffcc;
    }
    .avatar-uploader .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }

    .avatar-uploader .el-upload {
        border: 1px dashed var(--el-border-color);
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
        transition: var(--el-transition-duration-fast);
    }

        .avatar-uploader .el-upload:hover {
            border-color: var(--el-color-primary);
        }

    .el-icon.avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        text-align: center;
    }
</style>